"""
auth: 郝云浩
"""
from common.do_file_path import EXCEL_PATH, SHEET_NAME
from common.do_conf import ignore_project_s
from common.do_log import do_log
from common.do_excel import DoExcel
from services.services import get_all_report_table_s


def write_to_excel():
    do_excel = DoExcel(EXCEL_PATH, SHEET_NAME)
    all_datas = get_all_report_table_s(ignore_project_s)
    try:
        do_log.info('所有报告数据为 : ' + str(all_datas))
        do_excel.write_list(all_datas)
    except PermissionError:
        do_log.info('数据获取成功 , 数据保存失败 , 请关闭 Excel 后再运行 ... ')
    else:
        do_log.info('数据获取成功 , 数据保存成功 , 请前往 Excel 进行查看 ... ')


"""
def write_to_excel_then_read():
    write_to_excel()
    do_excel = DoExcel(EXCEL_PATH, SHEET_NAME)
    all_data = do_excel.read()
    for item in all_data:
        print(item)
"""

if __name__ == '__main__':
    write_to_excel()
    pass
